package com.smartrobot.smartrobot.activity;

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;


public class LoginActivityTest extends ActivityInstrumentationTestCase2<LoginActivity> {

    private Solo solo;

    public LoginActivityTest() {
        super(LoginActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());

    }

    @Override
    public void tearDown() throws Exception {

        solo.finishOpenedActivities();

    }

    public void testUI() throws Exception{

        //预期结果
        boolean expected = true;

        //结果结果
        boolean actual = solo.searchText("注册新账户");

        assertEquals("test if have button",expected, actual);

        solo.clickOnButton(0);

    }
//
    public void testLogin() throws Exception{

        //预期结果
        boolean expected = true;
        //结果结果
//        solo.enterText(0, "13828421070");
//        solo.enterText(1, "1992219");
        solo.clickOnButton("登陆");

        boolean actual =solo.searchText("登陆成功!");
//		boolean actual1 =solo.searchText("登陆失败");


        assertEquals("test if have button",expected, actual);
//		assertEquals("test if have button",expected, actual1);


    }

//    public void testLoginPhoneError() throws Exception{
//
//        //预期结果
////        boolean expected = true;
////        //结果结果
////        solo.enterText(0, "189259611291");
////        solo.enterText(1, "123456");
////        solo.clickOnButton("登陆");
////
////        boolean actual =solo.searchText("手机号码位数有误");
////        assertEquals("test if have button",expected, actual);
////
////        solo.clearEditText(0);
////        solo.enterText(0, "1892596112");
////        solo.clickOnButton("登陆");
////        boolean actual1 =solo.searchText("手机号码位数有误");
////        assertEquals("test if have button",expected, actual1);
////
////        solo.clearEditText(0);
////        solo.clearEditText(1);
////        solo.enterText(0, "18925961129");
////        solo.enterText(1, "12345");
////        solo.clickOnButton("登陆");
////        boolean actual2 =solo.searchText("密码只能够是6-12位");
////        assertEquals("test if have button",expected, actual2);
////
////        solo.clearEditText(0);
////        solo.clearEditText(1);
////        solo.enterText(0, "18925961129");
////        solo.enterText(1, "1234567890123");
////        solo.clickOnButton("登陆");
////        boolean actual3 =solo.searchText("密码只能够是6-12位");
////        assertEquals("test if have button",expected, actual3);
//
//
//    }
//
//    public void testSwitchRole(){
//
////        boolean expected = true;
////        solo.clickOnText("注册新账户");
////        solo.clickOnScreen(240, 335);
////        // 结果结果
////        solo.enterText(0, "18925961129");
////        solo.clickOnButton("获得验证码");
////        solo.enterText(2, "123456");
////        solo.enterText(3, "123456");
////        solo.enterText(4, "广州市沙宣总店");
////        solo.enterText(5, "18925961123");
////        solo.clickOnButton("注册");
//////
////        boolean actual = solo.searchText("创建门店");
//
//        assertEquals("test if have button",expected, actual);
//
//    }

}